/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Cali.java
 *
 * Created on 10-dic-2009, 18:52:06
 */
package GUI;

import Controlador.Controlador;
import Modelo.Alertas;
import Modelo.CalculosDatos;
import Modelo.Idiomas.LocaleManager;
import Utils.Ficheros.FicheroDatos;
import Utils.Util;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.io.FileNotFoundException;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class old_GUI_Navegacion extends javax.swing.JDialog {

    private static Controlador controlador;
    private static JPanel mapa;
    private static Vector rutaLatLong; //Contiene FicheroDatos (para guardar las lat/long en ficheros)
    private boolean modoMarcar;
    private boolean modoGrabar;
    private int zoom;
    private double latitudPressed, longitudPressed;
    private double latitudDraggedAntigua, longitudDraggedAntigua;
    private FicheroDatos vueltaDragg;
    private FicheroDatos centro;
    private FicheroDatos centroOriginal;
    private Cursor defaultCursor;
    private boolean modoDragged; //Indica si estamos explorando el mapa (dragg)
    private FicheroDatos centroDragg;

    public old_GUI_Navegacion(JFrame parent) {
        super(parent, true);
        initComponents();
        inicializarValores();
        cambioIdioma();
        centrarAplicacion();
        parent.setVisible(false);
        setVisible(true);
    }

    public static JPanel getDisplayMapa() {
        return mapa;
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BGmapType = new javax.swing.ButtonGroup();
        DPMapa = new javax.swing.JDesktopPane();
        PMapa = new javax.swing.JPanel();
        BVolverDelDragg = new javax.swing.JButton();
        DPCargar = new javax.swing.JPanel();
        BCargarMapa = new javax.swing.JButton();
        DPZoom = new javax.swing.JPanel();
        BZoomMas = new javax.swing.JButton();
        BZoomMenos = new javax.swing.JButton();
        DPDatos = new javax.swing.JPanel();
        LLatitud = new javax.swing.JLabel();
        TXTLatitud = new javax.swing.JTextField();
        TXTVelocidad = new javax.swing.JTextField();
        LVelocidad = new javax.swing.JLabel();
        TXTDistancia = new javax.swing.JTextField();
        LDistancia = new javax.swing.JLabel();
        TXTLongitud = new javax.swing.JTextField();
        LLongitud = new javax.swing.JLabel();
        RBroadmap = new javax.swing.JRadioButton();
        RBhybrid = new javax.swing.JRadioButton();
        RBsatellite = new javax.swing.JRadioButton();
        RBterrain = new javax.swing.JRadioButton();
        PRutas = new javax.swing.JPanel();
        BMarcarRuta = new javax.swing.JButton();
        BDeshacerMarca = new javax.swing.JButton();
        BBorrarRuta = new javax.swing.JButton();
        BCargarRuta = new javax.swing.JButton();
        BMostrarRuta = new javax.swing.JCheckBox();
        BGrabarRuta = new javax.swing.JButton();
        PCursores = new javax.swing.JPanel();
        BSubeIzq = new javax.swing.JButton();
        BSube = new javax.swing.JButton();
        BSubeDrch = new javax.swing.JButton();
        BIzq = new javax.swing.JButton();
        BBajaIzq = new javax.swing.JButton();
        BBaja = new javax.swing.JButton();
        BBajaDrch = new javax.swing.JButton();
        BDrch = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        BSalir = new javax.swing.JButton();
        BHybrid = new javax.swing.JButton();
        BTerrainN = new javax.swing.JButton();
        BRoadmap = new javax.swing.JButton();
        BSatellite = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("");
        setResizable(false);

        DPMapa.setBackground(new java.awt.Color(235, 233, 237));
        DPMapa.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Mapa", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N
        DPMapa.setForeground(new java.awt.Color(235, 233, 237));
        DPMapa.setPreferredSize(new java.awt.Dimension(650, 560));

        PMapa.setToolTipText("");
        PMapa.setName("Mapa"); // NOI18N
        PMapa.setPreferredSize(new java.awt.Dimension(633, 548));
        PMapa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                PMapaMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                PMapaMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                PMapaMouseReleased(evt);
            }
        });
        PMapa.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                PMapaMouseDragged(evt);
            }
        });

        BVolverDelDragg.setForeground(java.awt.Color.red);
        BVolverDelDragg.setText("Volver");
        BVolverDelDragg.setFocusPainted(false);
        BVolverDelDragg.setOpaque(false);
        BVolverDelDragg.setVisible(false);
        BVolverDelDragg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BVolverDelDraggActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PMapaLayout = new javax.swing.GroupLayout(PMapa);
        PMapa.setLayout(PMapaLayout);
        PMapaLayout.setHorizontalGroup(
            PMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PMapaLayout.createSequentialGroup()
                .addContainerGap(571, Short.MAX_VALUE)
                .addComponent(BVolverDelDragg))
        );
        PMapaLayout.setVerticalGroup(
            PMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PMapaLayout.createSequentialGroup()
                .addContainerGap(526, Short.MAX_VALUE)
                .addComponent(BVolverDelDragg))
        );

        PMapa.setBounds(10, 20, 633, 548);
        DPMapa.add(PMapa, javax.swing.JLayeredPane.DEFAULT_LAYER);

        DPCargar.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        BCargarMapa.setText("Cargar Mapa");
        BCargarMapa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCargarMapaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout DPCargarLayout = new javax.swing.GroupLayout(DPCargar);
        DPCargar.setLayout(DPCargarLayout);
        DPCargarLayout.setHorizontalGroup(
            DPCargarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DPCargarLayout.createSequentialGroup()
                .addContainerGap(136, Short.MAX_VALUE)
                .addComponent(BCargarMapa, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(99, 99, 99))
        );
        DPCargarLayout.setVerticalGroup(
            DPCargarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(BCargarMapa, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
        );

        DPZoom.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Zoom", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        BZoomMas.setFont(new java.awt.Font("Arial", 2, 12));
        BZoomMas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonZoomIn.PNG"))); // NOI18N
        BZoomMas.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextZoomMas"));
        BZoomMas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BZoomMasActionPerformed(evt);
            }
        });

        BZoomMenos.setFont(new java.awt.Font("Arial", 2, 12));
        BZoomMenos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonZoomOut.png"))); // NOI18N
        BZoomMenos.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextZoomMenos"));
        BZoomMenos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BZoomMenosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout DPZoomLayout = new javax.swing.GroupLayout(DPZoom);
        DPZoom.setLayout(DPZoomLayout);
        DPZoomLayout.setHorizontalGroup(
            DPZoomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DPZoomLayout.createSequentialGroup()
                .addContainerGap(70, Short.MAX_VALUE)
                .addComponent(BZoomMas, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(BZoomMenos, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(55, 55, 55))
        );
        DPZoomLayout.setVerticalGroup(
            DPZoomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DPZoomLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(DPZoomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BZoomMas, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BZoomMenos, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        DPDatos.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true), "Datos", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14))); // NOI18N

        LLatitud.setText("Latitud");

        TXTLatitud.setEditable(false);
        TXTLatitud.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTLatitud.setText("0.0");

        TXTVelocidad.setEditable(false);
        TXTVelocidad.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTVelocidad.setText("0.0");

        LVelocidad.setText("Velocidad (Km/h)");

        TXTDistancia.setEditable(false);
        TXTDistancia.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTDistancia.setText("0.0");

        LDistancia.setText("Distancia (Km)");

        TXTLongitud.setEditable(false);
        TXTLongitud.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        TXTLongitud.setText("0.0");

        LLongitud.setText("Longitud");

        javax.swing.GroupLayout DPDatosLayout = new javax.swing.GroupLayout(DPDatos);
        DPDatos.setLayout(DPDatosLayout);
        DPDatosLayout.setHorizontalGroup(
            DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DPDatosLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(DPDatosLayout.createSequentialGroup()
                        .addComponent(LLatitud, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(TXTLatitud, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(DPDatosLayout.createSequentialGroup()
                        .addComponent(LLongitud, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(TXTLongitud, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(29, 29, 29)
                .addGroup(DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(DPDatosLayout.createSequentialGroup()
                        .addComponent(LVelocidad, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(TXTVelocidad, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(DPDatosLayout.createSequentialGroup()
                        .addComponent(LDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(TXTDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(108, Short.MAX_VALUE))
        );
        DPDatosLayout.setVerticalGroup(
            DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DPDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(DPDatosLayout.createSequentialGroup()
                        .addGroup(DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LVelocidad)
                            .addComponent(TXTVelocidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LDistancia)
                            .addComponent(TXTDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(DPDatosLayout.createSequentialGroup()
                        .addGroup(DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LLatitud)
                            .addComponent(TXTLatitud, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(DPDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LLongitud)
                            .addComponent(TXTLongitud, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        BGmapType.add(RBroadmap);
        RBroadmap.setSelected(true);
        RBroadmap.setText("Roadmap");
        RBroadmap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBroadmapActionPerformed(evt);
            }
        });

        BGmapType.add(RBhybrid);
        RBhybrid.setText("Hybrid");
        RBhybrid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBhybridActionPerformed(evt);
            }
        });

        BGmapType.add(RBsatellite);
        RBsatellite.setText("Satellite");
        RBsatellite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBsatelliteActionPerformed(evt);
            }
        });

        BGmapType.add(RBterrain);
        RBterrain.setText("Terrain");
        RBterrain.setEnabled(false);
        RBterrain.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBterrainActionPerformed(evt);
            }
        });

        PRutas.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 103, 213), 3, true), "Modo Rutas", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14))); // NOI18N

        BMarcarRuta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/marcador.png"))); // NOI18N
        BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextMarcar"));
        BMarcarRuta.setActionCommand("JBMarcarRuta");
        BMarcarRuta.setPreferredSize(new java.awt.Dimension(40, 41));
        BMarcarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMarcarRutaActionPerformed(evt);
            }
        });

        BDeshacerMarca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonDeshacer_naranja.png"))); // NOI18N
        BDeshacerMarca.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextDeshacer"));
        BDeshacerMarca.setEnabled(false);
        BDeshacerMarca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BDeshacerMarcaActionPerformed(evt);
            }
        });

        BBorrarRuta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonBorrar.png"))); // NOI18N
        BBorrarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextBorrar"));
        BBorrarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BBorrarRutaActionPerformed(evt);
            }
        });

        BCargarRuta.setText("Cargar ruta");
        BCargarRuta.setActionCommand("JBCargarRuta");
        BCargarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCargarRutaActionPerformed(evt);
            }
        });

        BMostrarRuta.setSelected(true);
        BMostrarRuta.setText("Mostrar Ruta");
        BMostrarRuta.setEnabled(false);
        BMostrarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMostrarRutaActionPerformed(evt);
            }
        });

        BGrabarRuta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/botonGrabarOff.png"))); // NOI18N
        BGrabarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextRec"));
        BGrabarRuta.setActionCommand("JBGrabarRuta");
        BGrabarRuta.setIconTextGap(0);
        BGrabarRuta.setPreferredSize(new java.awt.Dimension(60, 70));
        BGrabarRuta.setRequestFocusEnabled(false);
        BGrabarRuta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGrabarRutaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PRutasLayout = new javax.swing.GroupLayout(PRutas);
        PRutas.setLayout(PRutasLayout);
        PRutasLayout.setHorizontalGroup(
            PRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PRutasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PRutasLayout.createSequentialGroup()
                        .addComponent(BCargarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(184, 184, 184))
                    .addGroup(PRutasLayout.createSequentialGroup()
                        .addGroup(PRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(BMostrarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(PRutasLayout.createSequentialGroup()
                                .addComponent(BMarcarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(BDeshacerMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(BBorrarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE)
                                .addComponent(BGrabarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())))
        );
        PRutasLayout.setVerticalGroup(
            PRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PRutasLayout.createSequentialGroup()
                .addComponent(BCargarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19)
                .addGroup(PRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BGrabarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(PRutasLayout.createSequentialGroup()
                        .addGroup(PRutasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(BMarcarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BDeshacerMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 4, Short.MAX_VALUE)
                        .addComponent(BMostrarRuta))
                    .addComponent(BBorrarRuta, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        PCursores.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 103, 213), 3, true), "Cursores", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14))); // NOI18N

        BSubeIzq.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorNoroeste.png"))); // NOI18N
        BSubeIzq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSubeIzqActionPerformed(evt);
            }
        });

        BSube.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorNorte.png"))); // NOI18N
        BSube.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSubeActionPerformed(evt);
            }
        });

        BSubeDrch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorNoreste.png"))); // NOI18N
        BSubeDrch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSubeDrchActionPerformed(evt);
            }
        });

        BIzq.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorOeste.png"))); // NOI18N
        BIzq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BIzqActionPerformed(evt);
            }
        });

        BBajaIzq.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorSuroeste.png"))); // NOI18N
        BBajaIzq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BBajaIzqActionPerformed(evt);
            }
        });

        BBaja.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorSur.png"))); // NOI18N
        BBaja.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BBajaActionPerformed(evt);
            }
        });

        BBajaDrch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorSureste.png"))); // NOI18N
        BBajaDrch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BBajaDrchActionPerformed(evt);
            }
        });

        BDrch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/Imagenes/cursorEste.png"))); // NOI18N
        BDrch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BDrchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PCursoresLayout = new javax.swing.GroupLayout(PCursores);
        PCursores.setLayout(PCursoresLayout);
        PCursoresLayout.setHorizontalGroup(
            PCursoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PCursoresLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PCursoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PCursoresLayout.createSequentialGroup()
                        .addComponent(BSubeIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BSube, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BSubeDrch, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(PCursoresLayout.createSequentialGroup()
                        .addComponent(BIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                        .addComponent(BDrch, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(PCursoresLayout.createSequentialGroup()
                        .addComponent(BBajaIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BBaja, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BBajaDrch, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        PCursoresLayout.setVerticalGroup(
            PCursoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PCursoresLayout.createSequentialGroup()
                .addGroup(PCursoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BSubeIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BSube, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BSubeDrch, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PCursoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BDrch, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PCursoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BBajaDrch, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BBaja, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BBajaIzq, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 103, 213), 3, true));

        BSalir.setFont(new java.awt.Font("Tahoma", 0, 18));
        BSalir.setText("Salir");
        BSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BSalir, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(BSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        BHybrid.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/geography-map-icon.png"))); // NOI18N
        BHybrid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BHybridActionPerformed(evt);
            }
        });

        BTerrainN.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/inkscape-icon.png"))); // NOI18N
        BTerrainN.setEnabled(false);
        BTerrainN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTerrainNActionPerformed(evt);
            }
        });

        BRoadmap.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/map-64x64.png"))); // NOI18N
        BRoadmap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BRoadmapActionPerformed(evt);
            }
        });

        BSatellite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/planet-world-icon.png"))); // NOI18N
        BSatellite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSatelliteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(DPDatos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(DPMapa, javax.swing.GroupLayout.DEFAULT_SIZE, 653, Short.MAX_VALUE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(DPCargar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(PRutas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(BSatellite, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(RBsatellite))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(RBhybrid)
                                    .addComponent(BHybrid, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(RBroadmap)
                                    .addComponent(BRoadmap, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(RBterrain))
                                    .addComponent(BTerrainN, javax.swing.GroupLayout.PREFERRED_SIZE, 89, Short.MAX_VALUE)))))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(PCursores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(69, 69, 69)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(DPZoom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(DPMapa, javax.swing.GroupLayout.PREFERRED_SIZE, 578, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(DPCargar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(DPZoom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(BSatellite, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BRoadmap, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BHybrid, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BTerrainN, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(RBsatellite)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(RBroadmap)
                                .addComponent(RBterrain))
                            .addComponent(RBhybrid))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(PRutas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(DPDatos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(PCursores, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(19, 19, 19))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BIzqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BIzqActionPerformed
        controlador.getGeomantes().setSumaLatLong(0, -0.0001);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        if (modoMarcar) {
            centro = actual;
        }
        actualizarTXT();
}//GEN-LAST:event_BIzqActionPerformed

    private void BBajaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BBajaActionPerformed
        controlador.getGeomantes().setSumaLatLong(-0.0001, 0);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        centro = actual;
        actualizarTXT();
}//GEN-LAST:event_BBajaActionPerformed

    private void BDrchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BDrchActionPerformed
        controlador.getGeomantes().setSumaLatLong(0, 0.0001);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        if (modoMarcar) {
            centro = actual;
        }
        actualizarTXT();
}//GEN-LAST:event_BDrchActionPerformed

    private void BSubeIzqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSubeIzqActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setSumaLatLong(0.0001, -0.0001);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        centro = actual;
        actualizarTXT();
}//GEN-LAST:event_BSubeIzqActionPerformed

    private void BSubeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSubeActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setSumaLatLong(0.0001, 0);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        centro = actual;
        actualizarTXT();
}//GEN-LAST:event_BSubeActionPerformed

    private void BBajaIzqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BBajaIzqActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setSumaLatLong(-0.0001, -0.0001);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        centro = actual;
        actualizarTXT();
}//GEN-LAST:event_BBajaIzqActionPerformed

    private void BBajaDrchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BBajaDrchActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setSumaLatLong(-0.0001, 0.0001);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        centro = actual;
        actualizarTXT();
}//GEN-LAST:event_BBajaDrchActionPerformed

    private void BSubeDrchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSubeDrchActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setSumaLatLong(0.0001, 0.0001);
        FicheroDatos actual = new FicheroDatos(
                controlador.getGeomantes().getCoordenadas().getLatitud(),
                controlador.getGeomantes().getCoordenadas().getLongitud(),
                controlador.getGeomantes().getCoordenadas().getAltitud());
        if (modoGrabar) {
            rutaLatLong.addElement(actual);
            if ((actual.getLatitud() != -1) && (actual.getLongitud() != -1)) {
                controlador.anadeVectorRuta(CalculosDatos.calcular(actual));
            }
        }
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
        centro = actual;
        actualizarTXT();
}//GEN-LAST:event_BSubeDrchActionPerformed

    private void BCargarMapaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCargarMapaActionPerformed
        try {
            if (controlador.cargarMapa()) {
                Alertas.exitoCargarMapa(this);
            }
            navegar();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
}//GEN-LAST:event_BCargarMapaActionPerformed

    private void BZoomMasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BZoomMasActionPerformed
        if (controlador.getModoMapas() && zoom < 19) {
            controlador.getGeomantes().setNivelZoom(controlador.getGeomantes().getNivelZoom() + 1);
            zoom++;
            if (zoom > 15) {
                RBterrain.setEnabled(false);
                BTerrainN.setEnabled(false);
            }
            double nuevaEscala = dameEscala();
            CalculosDatos.setInfoGoogle(
                    controlador.getGeomantes().getCoordenadas(),
                    1899,
                    1644,
                    "WGS 84", nuevaEscala);
            controlador.getGeomantes().setEscala(nuevaEscala);
            controlador.getGeomantes().inicializarGmaps();
            if (controlador.getModoGrabacion()) {
                controlador.redibujarRuta(rutaLatLong);
            }
            controlador.repaintGeomantes(
                    controlador.getGeomantes().getCoordenadas(),
                    CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);
        }
}//GEN-LAST:event_BZoomMasActionPerformed

    private void BZoomMenosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BZoomMenosActionPerformed
        if (controlador.getModoMapas() && zoom > 15) {
            controlador.getGeomantes().setNivelZoom(controlador.getGeomantes().getNivelZoom() - 1);
            zoom--;
            if (zoom == 15) {
                RBterrain.setEnabled(true);
                BTerrainN.setEnabled(true);
            }
            double nuevaEscala = dameEscala();
            CalculosDatos.setInfoGoogle(
                    controlador.getGeomantes().getCoordenadas(),
                    1899,
                    1644,
                    "WGS 84", nuevaEscala);
            controlador.getGeomantes().setEscala(nuevaEscala);
            controlador.getGeomantes().inicializarGmaps();
            if (controlador.getModoGrabacion()) {
                controlador.redibujarRuta(rutaLatLong);
            }
            controlador.repaintGeomantes(
                    controlador.getGeomantes().getCoordenadas(),
                    CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);
        }
}//GEN-LAST:event_BZoomMenosActionPerformed

    private void BSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSalirActionPerformed
        controlador.reiniciarGeomantes();
        dispose();
}//GEN-LAST:event_BSalirActionPerformed

    private void RBsatelliteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBsatelliteActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setMapType("satellite");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        /*        controlador.repaintGeomantes(
        controlador.getGeomantes().getCoordenadas(),
        CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);*/
    }//GEN-LAST:event_RBsatelliteActionPerformed

    private void RBterrainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBterrainActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setMapType("terrain");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        /*        controlador.repaintGeomantes(
        controlador.getGeomantes().getCoordenadas(),
        CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);*/
    }//GEN-LAST:event_RBterrainActionPerformed

    private void RBroadmapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBroadmapActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setMapType("roadmap");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        /*        controlador.repaintGeomantes(
        controlador.getGeomantes().getCoordenadas(),
        CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);*/
    }//GEN-LAST:event_RBroadmapActionPerformed

    private void RBhybridActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBhybridActionPerformed
        // TODO add your handling code here:
        controlador.getGeomantes().setMapType("hybrid");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        /*        controlador.repaintGeomantes(
        controlador.getGeomantes().getCoordenadas(),
        CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);*/
    }//GEN-LAST:event_RBhybridActionPerformed

    private void BMostrarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMostrarRutaActionPerformed
        if (BMostrarRuta.isSelected()) {
            BMostrarRuta.setSelected(true);
            controlador.setMostrarRuta(true);
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            /*        controlador.repaintGeomantes(
            controlador.getGeomantes().getCoordenadas(),
            CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);*/
        } else {
            BMostrarRuta.setSelected(false);
            controlador.setMostrarRuta(false);
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            /*        controlador.repaintGeomantes(
            controlador.getGeomantes().getCoordenadas(),
            CalculosDatos.calcular(controlador.getGeomantes().getCoordenadas()), 20, 10);*/
        }
}//GEN-LAST:event_BMostrarRutaActionPerformed

    private void BBorrarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BBorrarRutaActionPerformed
        if (modoMarcar == true) {
            BMostrarRuta.setEnabled(false);
            BMarcarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/marcador.png")));
            BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextMarcar"));
            modoMarcar = false;
            BGrabarRuta.setEnabled(true);
            BCargarRuta.setEnabled(true);
            BDeshacerMarca.setEnabled(false);
            PMapa.setCursor(defaultCursor);
            controlador.setModoGrabacion(false);
            reiniciaRuta();
        }
}//GEN-LAST:event_BBorrarRutaActionPerformed

    private void BDeshacerMarcaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BDeshacerMarcaActionPerformed
        // TODO add your handling code here:
        if (controlador.getVectorRuta().size() > 0) {
            controlador.deshacerMarcarRuta();
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
        }
}//GEN-LAST:event_BDeshacerMarcaActionPerformed

    private void BGrabarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGrabarRutaActionPerformed
        if (modoGrabar == false) {
            BMostrarRuta.setEnabled(true);
            rutaLatLong = new Vector();
            modoGrabar = true;
            controlador.setModoGrabacion(true);
            BMarcarRuta.setEnabled(false);
            BDeshacerMarca.setEnabled(false);
            BCargarRuta.setEnabled(false);
            BBorrarRuta.setEnabled(false);
            //Guardamos como primera posición la del centro del mapa en ese instante
            centro.setLatitud(controlador.getGeomantes().getCoordenadas().getLatitud());
            centro.setLongitud(controlador.getGeomantes().getCoordenadas().getLongitud());
            controlador.anadeVectorRuta(CalculosDatos.calcular(centro));
            BGrabarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/botonGrabarOn.png")));
        } else {
            BMostrarRuta.setEnabled(false);
            modoGrabar = false;
            if (controlador.guardarRuta(rutaLatLong)) {
                Alertas.exitoGuardarRuta(this);
            } else {
                Alertas.falloGuardarRuta(this);
            }
            reiniciaRuta();
            BMarcarRuta.setEnabled(true);
            BDeshacerMarca.setEnabled(true);
            BCargarRuta.setEnabled(true);
            BBorrarRuta.setEnabled(true);
            BGrabarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/botonGrabarOff.png")));
        }
}//GEN-LAST:event_BGrabarRutaActionPerformed

    private void BMarcarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMarcarRutaActionPerformed
        if (modoMarcar == false) {
            BMostrarRuta.setEnabled(true);
            modoMarcar = true;
            rutaLatLong = new Vector();
            controlador.setModoGrabacion(true);
            Image imagenCursor = Toolkit.getDefaultToolkit().getImage(Toolkit.getDefaultToolkit().getClass().getResource("/Archivos/Imagenes/marcador.png"));
            Point hotSpot = new Point(0, 0);
            Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(imagenCursor, hotSpot, "cursorMarcar");
            PMapa.setCursor(cursor);
            BGrabarRuta.setEnabled(false);
            BCargarRuta.setEnabled(false);
            BMarcarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/botonGuardar.png")));
            BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextGuardar"));
        } else {
            BMostrarRuta.setEnabled(false);
            BMarcarRuta.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/Archivos/Imagenes/marcador.png")));
            BMarcarRuta.setToolTipText(LocaleManager.getMessage("navegacionToolTilTextMarcar"));
            modoMarcar = false;
            BGrabarRuta.setEnabled(true);
            BCargarRuta.setEnabled(true);
            BDeshacerMarca.setEnabled(false);
            PMapa.setCursor(defaultCursor);
            if (controlador.guardarRuta(rutaLatLong)) {
                Alertas.exitoGuardarRuta(this);
            } else {
                Alertas.falloGuardarRuta(this);
            }
            reiniciaRuta();
        }
}//GEN-LAST:event_BMarcarRutaActionPerformed

    private void BCargarRutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCargarRutaActionPerformed
        try {
            if (controlador.cargarRuta()) {
                Alertas.exitoCargarRuta(this);
                BMostrarRuta.setEnabled(true);
                controlador.setModoGrabacion(true);
                FicheroDatos actual = new FicheroDatos(
                        controlador.getGeomantes().getCoordenadas().getLatitud(),
                        controlador.getGeomantes().getCoordenadas().getLongitud(),
                        controlador.getGeomantes().getCoordenadas().getAltitud());
                controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
            }
        } catch (FileNotFoundException ex) {
            Alertas.falloCargarRuta(this);
        }

}//GEN-LAST:event_BCargarRutaActionPerformed
    private void BHybridActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BHybridActionPerformed
        controlador.getGeomantes().setMapType("hybrid");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BHybridActionPerformed

    private void BTerrainNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTerrainNActionPerformed
        controlador.getGeomantes().setMapType("terrain");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BTerrainNActionPerformed

    private void BRoadmapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BRoadmapActionPerformed
        controlador.getGeomantes().setMapType("roadmap");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BRoadmapActionPerformed

    private void BSatelliteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSatelliteActionPerformed
        controlador.getGeomantes().setMapType("satellite");
        controlador.getGeomantes().inicializarGmaps();
        try {
            controlador.procesarRutaEnMapa();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
}//GEN-LAST:event_BSatelliteActionPerformed

    private void PMapaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMousePressed
        if (evt.isMetaDown()) {
            if (!modoDragged) {
                vueltaDragg = new FicheroDatos(centro.getLatitud(), centro.getLongitud(), 22);
                modoDragged = true;
                BVolverDelDragg.setVisible(true);
                vueltaDragg = new FicheroDatos(centro.getLatitud(), centro.getLongitud(),22);
            }
            controlador.getGeomantes().setModoDragged(true);

            double[] latlong = dameLatLong(evt);
            latitudPressed = latlong[0];
            longitudPressed = latlong[1];
            latitudDraggedAntigua = latlong[0];
            longitudDraggedAntigua = latlong[1];
            BVolverDelDragg.repaint();
        }
    }//GEN-LAST:event_PMapaMousePressed

    private void PMapaMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseReleased
        if (evt.isMetaDown()) {
            controlador.getGeomantes().setCoordenadas(centro);
            controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            actualizarTXT();
            BVolverDelDragg.repaint();
        }
    }//GEN-LAST:event_PMapaMouseReleased

    private void PMapaMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseDragged
        if (evt.isMetaDown()) {
            double[] latlong = dameLatLong(evt);
            double latitud = latlong[0];
            double longitud = latlong[1];
            double restaLat = latitudDraggedAntigua - latitud;
            double restaLong = longitudDraggedAntigua - longitud;
            controlador.getGeomantes().setSumaLatLong(restaLat, restaLong);
            FicheroDatos actual = new FicheroDatos(
                    controlador.getGeomantes().getCoordenadas().getLatitud(),
                    controlador.getGeomantes().getCoordenadas().getLongitud(),
                    controlador.getGeomantes().getCoordenadas().getAltitud());
            controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
            centro = actual;
            actualizarTXT();
            BVolverDelDragg.repaint();
        }
    }//GEN-LAST:event_PMapaMouseDragged

    private void PMapaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PMapaMouseClicked
        if (!evt.isMetaDown()) {
            if (controlador.getVectorRuta() != null && controlador.getVectorRuta().size() > 0) {
                BDeshacerMarca.setEnabled(true);
            } else {
                BDeshacerMarca.setEnabled(false);
            }

            if (modoMarcar) {
                double[] latlong;
                latlong = dameLatLong(evt);
                double latitud = latlong[0];
                double longitud = latlong[1];
                FicheroDatos infoLinea = new FicheroDatos(latitud, longitud, controlador.getGeomantes().getCoordenadas().getAltitud());
                if ((infoLinea.getLatitud() != -1) && (infoLinea.getLongitud() != -1)) {
                    controlador.anadeVectorRuta(CalculosDatos.calcular(infoLinea));
                    rutaLatLong.addElement(infoLinea);
                }
                controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), 0, 0, 0, 0);
            }
            BVolverDelDragg.repaint();
        }
    }//GEN-LAST:event_PMapaMouseClicked

    private void BVolverDelDraggActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BVolverDelDraggActionPerformed
        centro = vueltaDragg;
        controlador.getGeomantes().setModoDragged(true);
        controlador.getGeomantes().setCoordenadas(vueltaDragg);
        controlador.repaintGeomantes(vueltaDragg, CalculosDatos.calcular(vueltaDragg), 20, 10);
        modoDragged = false;
        BVolverDelDragg.setVisible(false);
    }//GEN-LAST:event_BVolverDelDraggActionPerformed
//
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BBaja;
    private javax.swing.JButton BBajaDrch;
    private javax.swing.JButton BBajaIzq;
    private javax.swing.JButton BBorrarRuta;
    private javax.swing.JButton BCargarMapa;
    private javax.swing.JButton BCargarRuta;
    private javax.swing.JButton BDeshacerMarca;
    private javax.swing.JButton BDrch;
    private javax.swing.ButtonGroup BGmapType;
    private javax.swing.JButton BGrabarRuta;
    private javax.swing.JButton BHybrid;
    private javax.swing.JButton BIzq;
    private javax.swing.JButton BMarcarRuta;
    private javax.swing.JCheckBox BMostrarRuta;
    private javax.swing.JButton BRoadmap;
    private javax.swing.JButton BSalir;
    private javax.swing.JButton BSatellite;
    private javax.swing.JButton BSube;
    private javax.swing.JButton BSubeDrch;
    private javax.swing.JButton BSubeIzq;
    private javax.swing.JButton BTerrainN;
    private javax.swing.JButton BVolverDelDragg;
    private javax.swing.JButton BZoomMas;
    private javax.swing.JButton BZoomMenos;
    private javax.swing.JPanel DPCargar;
    private javax.swing.JPanel DPDatos;
    private javax.swing.JDesktopPane DPMapa;
    private javax.swing.JPanel DPZoom;
    private javax.swing.JLabel LDistancia;
    private javax.swing.JLabel LLatitud;
    private javax.swing.JLabel LLongitud;
    private javax.swing.JLabel LVelocidad;
    private javax.swing.JPanel PCursores;
    private javax.swing.JPanel PMapa;
    private javax.swing.JPanel PRutas;
    private javax.swing.JRadioButton RBhybrid;
    private javax.swing.JRadioButton RBroadmap;
    private javax.swing.JRadioButton RBsatellite;
    private javax.swing.JRadioButton RBterrain;
    private javax.swing.JTextField TXTDistancia;
    private javax.swing.JTextField TXTLatitud;
    private javax.swing.JTextField TXTLongitud;
    private javax.swing.JTextField TXTVelocidad;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

    private void centrarAplicacion() {
        int width = this.getWidth();
        int height = this.getHeight();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width - width) / 2;
        int y = (screen.height - height) / 2;
        setBounds(x, y, width, height);
    }

    private void navegar() {
        mapa.setBorder(controlador.getGeomantes());
        FicheroDatos actual = controlador.getGeomantes().getCoordenadas();
        controlador.repaintGeomantes(actual, CalculosDatos.calcular(actual), 20, 10);
    }

    private double dameEscala() {
        if (controlador.getGeomantes().getNivelZoom() == 15) {
            return 3.7037037037037037037037037037037;
        }

        if (controlador.getGeomantes().getNivelZoom() == 16) {
            return 1.8348623853211009174311926605505;
        }

        if (controlador.getGeomantes().getNivelZoom() == 17) {
            return 0.91743119266055045871559633027523;
        }

        if (controlador.getGeomantes().getNivelZoom() == 18) {
            return 0.45871559633027522935779816513761;
        }

        if (controlador.getGeomantes().getNivelZoom() == 19) {
            return 0.22988505747126436781609195402299;
        }

        return 0.91743119266055045871559633027523;
    }

    private void actualizarTXT() {
        FicheroDatos actual = controlador.getGeomantes().getCoordenadas();
        TXTLatitud.setText(String.valueOf(actual.getLatitud()));
        TXTLongitud.setText(String.valueOf(actual.getLongitud()));
        TXTVelocidad.setText(String.valueOf(controlador.getGeomantes().getVelocidad()));
        TXTDistancia.setText(String.valueOf(controlador.getGeomantes().getDistancia()));
    }

    private void reiniciaRuta() {
        rutaLatLong = new Vector();
        controlador.iniciaRutaMarcada();
        controlador.getGeomantes().paintBorder(this, PMapa.getGraphics(), zoom, zoom, WIDTH, WIDTH);
    }

    private void cambioIdioma() {
        this.setTitle(LocaleManager.getMessage("navegacionTitulo"));
        this.LLatitud.setText(LocaleManager.getMessage("navegacionLabelLongitud"));
        this.LLongitud.setText(LocaleManager.getMessage("navegacionLabelLongitud"));
        this.LVelocidad.setText(LocaleManager.getMessage("navegacionLabelVelocidad"));
        this.LDistancia.setText(LocaleManager.getMessage("navegacionLabelDistancia"));
        this.BCargarMapa.setText(LocaleManager.getMessage("navegacionCargarMapa"));
        this.BCargarRuta.setText(LocaleManager.getMessage("navegacionCargarRuta"));
        this.BSalir.setText(LocaleManager.getMessage("navegacionSalir"));
        this.BMostrarRuta.setText(LocaleManager.getMessage("navegacionMostrarRuta"));
        this.PCursores.setBorder(
                javax.swing.BorderFactory.createTitledBorder(
                new javax.swing.border.LineBorder(
                new java.awt.Color(102, 153, 255), 3, true),
                LocaleManager.getMessage("navegacionCursores"),
                javax.swing.border.TitledBorder.CENTER,
                javax.swing.border.TitledBorder.TOP,
                new java.awt.Font("Arial", 1, 14)));
        this.PRutas.setBorder(
                javax.swing.BorderFactory.createTitledBorder(
                new javax.swing.border.LineBorder(
                new java.awt.Color(102, 153, 255), 3, true),
                LocaleManager.getMessage("navegacionModoRuta"),
                javax.swing.border.TitledBorder.CENTER,
                javax.swing.border.TitledBorder.DEFAULT_POSITION,
                new java.awt.Font("Arial", 1, 14),
                new java.awt.Color(102, 153, 255)));
        this.DPDatos.setBorder(
                javax.swing.BorderFactory.createTitledBorder(
                new javax.swing.border.LineBorder(
                new java.awt.Color(102, 153, 255), 3, true),
                LocaleManager.getMessage("calibracionCoordenadas"),
                javax.swing.border.TitledBorder.CENTER,
                javax.swing.border.TitledBorder.TOP,
                new java.awt.Font("Arial", 1, 14),
                new java.awt.Color(102, 153, 255)));
    }

    private void inicializarValores() {
        mapa = PMapa;
        controlador =
                InicioAplicacion.getControlador();
        controlador.setDisplayMapa(mapa);
        controlador.setModoNavegacion(false);
        try {
            controlador.iniciarGeomantes();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        if (controlador.getModoMapas() == true) { //Si modo GoogleMaps
            DPCargar.setVisible(false);
            controlador.getGeomantes().setEscala(dameEscala());
            CalculosDatos.setInfoGoogle(
                    controlador.getGeomantes().getCoordenadas(),
                    1899,
                    1644,
                    "WGS 84",
                    dameEscala());
            navegar();

        }
        //Nivel de zoom inicial = 17

        zoom = 17;

        // Para pintar rutas, en principio, desactivado
        modoMarcar = false;
        modoGrabar = false;

        // Si estamos explorando el mapa
        modoDragged = false;

        //Centro inicial del mapa
        centro = new FicheroDatos();
        centro.setLatitud(controlador.getGeomantes().getCoordenadas().getLatitud());
        centro.setLongitud(controlador.getGeomantes().getCoordenadas().getLongitud());

        //Centro original
        centroOriginal =
                new FicheroDatos();
        centroOriginal.setLatitud(controlador.getGeomantes().getCoordenadas().getLatitud());
        centroOriginal.setLongitud(controlador.getGeomantes().getCoordenadas().getLongitud());

        //Cursor por defecto para cuando dejemos de dibujar
        defaultCursor = PMapa.getCursor();

        //Marcamos las coordenadas iniciales en los cuadros de texto
        TXTLatitud.setText(String.valueOf(
                controlador.getGeomantes().getCoordenadas().getLatitud()));
        TXTLongitud.setText(String.valueOf(
                controlador.getGeomantes().getCoordenadas().getLongitud()));
    }

    private double[] dameLatLong(MouseEvent evt) {
        double[] latlong = new double[2];
        double latEsq = CalculosDatos.getLatEsqIzq();
        double lonEsq = CalculosDatos.getLongEsqIzq();

        double gradosX1 = lonEsq;
        double gradosY1 = latEsq;
        double gradosX2 = centro.getLongitud();
        double gradosY2 = centro.getLatitud();

        Point p = evt.getPoint();

        int pixelX2 = CalculosDatos.calcular(centro)[2];//2803;
        int pixelY2 = CalculosDatos.calcular(centro)[3];//2471;

        FicheroDatos esqIzq = new FicheroDatos(latEsq, lonEsq, 0);
        int pixelX1 = CalculosDatos.calcular(esqIzq)[2];// 0, al principio
        int pixelY1 = CalculosDatos.calcular(esqIzq)[3];// 0

        double restaPix = Math.abs(pixelX2 - pixelX1);
        double restaPixY = Math.abs(pixelY2 - pixelY1);
        double restaGrad = Math.abs(gradosX2 - gradosX1);
        double restaGradY = Math.abs(gradosY2 - gradosY1);

        double metrosporgradoX = Math.abs(Util.LLtoUTM(23, 1, 1).getUTMEasting());
        double metrosporgradoY = Math.abs(Util.LLtoUTM(23, 1, 1).getUTMNorthing());
        double escala = (restaGrad * metrosporgradoX) / restaPix; // metros/pixel
        double escalaY = (restaGradY * metrosporgradoY) / restaPixY; // metros/pixel
        int restaPixelesX = p.x - (mapa.getWidth() / 2);
        int restaPixelesY = p.y - (mapa.getHeight() / 2);
        double restaGradosX = (escala * restaPixelesX) / metrosporgradoX;
        double restaGradosY = (escalaY * restaPixelesY) / metrosporgradoY;
        double latitud = gradosY2 - restaGradosY;
        double longitud = gradosX2 + restaGradosX;
        latlong[0] = latitud;
        latlong[1] = longitud;
        return latlong;
    }
}
